package com.han.gateway.config;

import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Getter
@Configuration
@ConfigurationProperties(prefix = "ignore.validate")
public class IgnoreValidateUrlConfig {

    private final List<String> defaultIgnoreUrls = List.of("/login", "/validateToken");

    private List<String> urls = defaultIgnoreUrls;

    public void setUrls(List<String> urls) {
        List<String> newUrls = new ArrayList<>();
        newUrls.addAll(urls);
        newUrls.addAll(this.urls);
        this.urls = newUrls;
    }

    public boolean ignore(String url) {
        return urls.contains(url);
    }

}
